/**
 * \file
 */
#include <fuse.h>

struct fuse_operations* kfsys_fuse_ops();

/**
 */
int kfsys_access(const char* path, int mode);

/**
 * Change the permission bits of the file.
 */
int kfsys_chmod(const char *path, mode_t mode);

/**
 * Change the owning user and group of the file.
 */
int kfsys_chown(const char *path, uid_t, gid_t);

/**
 * Create an empty directory.
 */
int kfsys_create_dir(const char *path, mode_t mode);

/**
 * If the file does not exist, first create it with the specified mode, and
 * then open it.
 */
int kfsys_create_regfile(const char *path, mode_t mode, fuse_file_info* fi);

/**
 * Clean up filesystem.  Called on filesystem exit.  Introduced in version
 * 2.3.
 */
void kfsys_destroy(void*);

/**
 * The return value will passed in the private_data field of fuse_context to
 * all file operations and as a parameter to the destroy() method.
 */
void* kfsys_init(fuse_conn_info*);

/**
 * Get file attributes.
 *
 * Similar to stat(). The 'st_dev' and 'st_blksize' fields are ignored. The
 * 'st_ino' field is ignored except if the 'use_ino' mount option is given.
 */
int kfsys_getattr(const char *path, struct stat *stbuf);

/**
 * Get file attributes.  This operates on an already opened file.
 */
int kfsys_fgetattr(const char* path, struct stat* const mystat,
    fuse_file_info* fi);

/**
 * Open a file.
 */
int kfsys_open(const char *path, struct fuse_file_info *fi);

/**
 * Open a directory for reading.
 */
int kfsys_opendir(const char *path, struct fuse_file_info *fi);

int kfsys_read(const char *path, char *buf, size_t size, off_t fileStartPosition,
               struct fuse_file_info *fi);

int kfsys_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                  off_t offset, struct fuse_file_info *fi);

/**
 * For every open() call there will be exactly one release() call with the same flags and file descriptor
 */
int kfsys_release(char const* path, fuse_file_info*);

/**
 * For every opendir() call there will be exactly one releasedir() call with the same flags and file descriptor
 */
int kfsys_releasedir(char const* path, fuse_file_info*);

/**
 * Truncate or extend the given file so that it is precisely size bytes long.
 * See truncate(2) for details. This call is required for read/write
 * filesystems, because recreating a file will first truncate it.
 */
int kfsys_truncate(const char* path, off_t newSize);

/**
 * Truncate or extend the given file so that it is precisely size bytes long.
 * See truncate(2) for details.
 *
 * This method is called instead of @truncate() if the truncation was invoked
 * from an ftruncate() system call.  If this method is not implemented or under
 * Linux kernel versions prior to 2.6.15, the truncate() method will be called
 * instead.
 * @see kfsys_truncate()
 */
int kfsys_ftruncate(const char* path, off_t newSize, fuse_file_info* fi);

/**
 * Remove a file.
 */
int kfsys_unlink(char const* path);

/**
 * Change the access and modification times of a file with nanosecond
 * resolution.
 */
int kfsys_utimens(const char * path, const struct timespec tv[2]);


int kfsys_write(const char * path, const char *source, size_t numBytes,
    off_t fileStartPosition, struct fuse_file_info *);
